package com.cortex.carambola.view;

import java.util.Collections;
import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;


public class CortexAdapter<T> extends BaseAdapter {

	
	private OnActionViewListener<T> onActionViewListener;
	private List<T> list;

	public CortexAdapter(Context context,List<T> list) {
		this.list = list;
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public T getItem(int position) {
		// TODO Auto-generated method stub
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if(onActionViewListener != null){
			convertView = onActionViewListener.addView(convertView,(T)getItem(position),position);
		}
		return convertView;
	}
	
	public void setOnAddViewListener(OnActionViewListener<T> onActionViewListener) {
		this.onActionViewListener = onActionViewListener;
	}
	public interface OnActionViewListener<T>{
		View addView(View v,T t,int position);
	}

	

}
